import { defineStore } from 'pinia';

interface ObjectList {
    [key: string]: string[];
}

export const usePermissStore = defineStore('permiss', {
    state: () => {
        const defaultList: ObjectList = {
            admin: [
                'dashboard',
                'system',
                'system-user',
                'system-user-group',
                'system-menu',
                'member',
                'member-list',
                'member-detail',
                'coupon-list',
                'coupon-form',
                'prop-list',
                'prop-form',
                'level-list',
                'level-form',
                'task-list',
                'task-form',
                'service-provider',
                'service-provider-main',
                'service-provider-form',
                'service-provider-audit',
                'expert-list',
                'expert-audit',
                'order',
                'question-order-list',
                'question-order-detail',
                'service-order-list',
                'service-order-detail',
                'product-order-list',
                'product-order-detail',
                'product',
                'service-list',
                'service-form',
                'service-detail',
                'video-image-list',
                'video-image-form',
                'product-list',
                'product-form',
                'product-category-list',
                'product-category-form',
                'interest-list',
                'interest-form',
                'expertise-list',
                'expertise-form',
                'question-category-list',
                'question-category-form',
                'recommended-question-list',
                'recommended-question-form',
                'task-list',
                'task-form',
                'withdrawal-list',
                'withdrawal-audit',
                'platform-withdrawal-list',
                'withdrawal',
                'carousel',
                'carousel-list',
                'carousel-form',
                'topic-list',
                'topic-form',
                'activity-list',
                'activity-form',
                'faq-list',
                'faq-form',
                'sign-in-config',
                'icon',
                'theme',
                'pages',
                'ucenter',
                'editor',
                'login',
                'register',
                'reset-pwd',
                '403',
                '404',
            ],
            user: [
                'dashboard',
                'system',
                'system-user',
                'system-user-group',
                'system-menu',
                'member',
                'member-list',
                'member-detail',
                'coupon-list',
                'coupon-form',
                'prop-list',
                'prop-form',
                'level-list',
                'level-form',
                'task-list',
                'task-form',
                'service-provider',
                'service-provider-main',
                'service-provider-form',
                'service-provider-audit',
                'expert-list',
                'expert-audit',
                'order',
                'question-order-list',
                'question-order-detail',
                'service-order-list',
                'service-order-detail',
                'product-order-list',
                'product-order-detail',
                'product',
                'service-list',
                'service-form',
                'service-detail',
                'video-image-list',
                'video-image-form',
                'product-list',
                'product-form',
                'product-category-list',
                'product-category-form',
                'interest-list',
                'interest-form',
                'expertise-list',
                'expertise-form',
                'question-category-list',
                'question-category-form',
                'recommended-question-list',
                'recommended-question-form',
                'task-list',
                'task-form',
                'withdrawal-list',
                'withdrawal-audit',
                'platform-withdrawal-list',
                'withdrawal',
                'carousel',
                'carousel-list',
                'carousel-form',
                'topic-list',
                'topic-form',
                'activity-list',
                'activity-form',
                'faq-list',
                'faq-form',
                'sign-in-config',
            ],
        };
        const username = localStorage.getItem('vuems_name');
        console.log(username);
        return {
            key: (username == 'admin' ? defaultList.admin : defaultList.user) as string[],
            defaultList,
        };
    },
    actions: {
        handleSet(val: string[]) {
            this.key = val;
        },
    },
});
